<template>
	<view class="page">
		<uni-nav-bar fixed="true" statusBar :border="false" title="首页"></uni-nav-bar>
		<!-- 轮播图 -->
		<z-swiper v-model="swiperList" :options="options">
			<z-swiper-item :custom-style="{ width: '680rpx', height: '360rpx' }" class="swiper-item" v-for="(item, index) in swiperList" :key="index">
				<image :src="item"></image>
			</z-swiper-item>
		</z-swiper>
		<view class="cate-section">
			<view class="cate-item">
				<image src="/static/temp/c3.png"></image>
				<text>前端开发</text>
			</view>
			<view class="cate-item">
				<image src="/static/temp/c5.png"></image>
				<text>后端开发</text>
			</view>
			<view class="cate-item">
				<image src="/static/temp/c6.png"></image>
				<text>运维测试</text>
			</view>
			<view class="cate-item">
				<image src="/static/temp/c7.png"></image>
				<text>摄影技术</text>
			</view>
			<view class="cate-item">
				<image src="/static/temp/c8.png"></image>
				<text>艺术作品</text>
			</view>
		</view>
		<!-- 推荐好课 -->
		<view class="course">
			<view class="title">
				<text class="name">推荐好课</text>
				<text class="more">查看更多</text>
			</view>

			<view class="course-list">
				<view :key="index" v-for="(item, index) in 4" class="course-item">
					<image class="img" src="https://img2.mukewang.com/szimg/5fbf616b09c6210a12000676.png" mode=""></image>
					<view class="desc">
						<view class="desc-title text-line2">C语言系统化精讲 重塑编程思想 打造坚实的开发基础</view>
						<view class="desc-tag">
							<text>1452</text>
							<text>人购买</text>
						</view>
					</view>
					<view class="price">¥299</view>
				</view>
				<view class="list-more">查看更多</view>
			</view>
		</view>

		<!-- 推荐企业 -->
		<view class="enterprise">
			<view class="title">
				<text class="name">推荐企业</text>
				<text class="more">查看更多</text>
			</view>

			<scroll-view scroll-x="true" class="enterprise-list">
				<view :key="index" v-for="(item, index) in 4" class="enterprise-item">
					<image class="img" src="https://img2.mukewang.com/szimg/5fbf616b09c6210a12000676.png" mode="aspectFit"></image>
					<view class="tit">某某企业</view>
				</view>
			</scroll-view>
		</view>
	</view>
</template>
<script>
import { getSubject } from '@/services/personal.js';
export default {
	data() {
		return {
			background: ['color1', 'color2', 'color3'],

			options: {
				effect: 'coverflow',
				centeredSlides: true,
				slidesPerView: 'auto',
				coverflowEffect: {
					rotate: 40,
					stretch: 0,
					depth: 100,
					modifier: 1,
					slideShadows: true
				}
			},
			indicatorDots: true,
			autoplay: true,
			interval: 2000,
			duration: 500,
			swiperList: [
				'https://img.mukewang.com/623a879009aadf4e00000000.png',
				'https://img.mukewang.com/6253912409a6a56918000600.png ',
				'https://img.mukewang.com/623a879009aadf4e00000000.png'
			]
		};
	},
	onLoad() {
		this.getSubjectList()
	},
	methods: {
		async getSubjectList() {
			await getSubject();
		}
	}
};
</script>

<style scoped lang="scss">
@mixin text-overflow-more($line: 2) {
	white-space: normal;
	overflow: hidden;
	text-overflow: ellipsis;
	text-align: justify;
	display: -webkit-box;
	-webkit-line-clamp: $line;
	-webkit-box-orient: vertical;
}

.page {
	background-color: #fefefe;

	.swiper-item {
		// padding: 0 5rpx;
		// overflow: hidden;
		// border-radius: 20rpx;
		// width: 750rpx;
		// height: 350rpx;
		image {
			// margin: 0 30rpx;
			height: 100%;
			width: 100%;
			border-radius: 24rpx;
		}
	}
	/* 分类 */
	.cate-section {
		display: flex;
		justify-content: space-around;
		align-items: center;
		flex-wrap: wrap;
		padding: 30upx 22upx;
		background: #fff;
		.cate-item {
			display: flex;
			flex-direction: column;
			align-items: center;
			font-size: $font-sm + 2upx;
			color: $font-color-dark;
		}
		/* 原图标颜色太深,不想改图了,所以加了透明度 */
		image {
			width: 88upx;
			height: 88upx;
			margin-bottom: 14upx;
			border-radius: 50%;
			opacity: 0.7;
			box-shadow: 4upx 4upx 20upx rgba(250, 67, 106, 0.3);
		}
	}
	.course {
		// margin-top: 20rpx;
		padding: 30rpx 30rpx 0;
		background-color: #ffffff;
		.title {
			display: flex;
			justify-content: space-between;
			align-items: center;
			height: 60rpx;
			background-image: url(/static/index/title-bg-3.png);
			background-size: auto 80rpx;
			background-repeat: no-repeat;

			.name {
				padding-left: 10rpx;
				font-size: 36rpx;
				font-weight: 600;
			}

			.more {
				font-size: 28rpx;
				color: #b7bbbf;
			}
		}

		.course-list {
			.course-item {
				display: flex;
				align-items: center;
				height: 150rpx;
				margin-top: 20rpx;
				.img {
					height: 150rpx;
					width: 200rpx;
					border-radius: 15rpx;
				}

				.desc {
					display: flex;
					flex-direction: column;
					justify-content: space-between;
					height: 130rpx;
					flex: 1;
					margin: 0 20rpx;
					.desc-title {
						font-size: 30rpx;
						color: #2b333b;
					}
					.desc-tag {
						font-size: 28rpx;
						color: #71777d;
					}
				}
				.price {
					display: flex;
					align-items: center;
					justify-content: center;
					width: 120rpx;
					height: 60rpx;
					background: rgba(43, 51, 59, 0.06);
					border-radius: 40rpx;
					font-weight: 500;
					font-size: 30rpx;
					color: #71777d;
				}
			}
		}
	}
	.enterprise {
		background-color: #f9f9f9;
		padding: 30rpx 0 30rpx 30rpx;
		.title {
			display: flex;
			justify-content: space-between;
			align-items: center;
			height: 60rpx;
			background-image: url(/static/index/title-bg-2.png);
			background-size: auto 80rpx;
			background-repeat: no-repeat;

			.name {
				padding-left: 10rpx;
				font-size: 36rpx;
				font-weight: 600;
			}

			.more {
				padding-right: 10rpx;
				font-size: 28rpx;
				color: #b7bbbf;
			}
		}
		.enterprise-list {
			display: flex;
			white-space: nowrap;
			width: 100%;
			.enterprise-item {
				background-color: #ffffff;
				margin-top: 20rpx;
				display: inline-block;
				overflow: hidden;
				border-radius: 20rpx;
				margin-right: 30rpx;
				width: 300rpx;
				height: 400rpx;
				.img {
					width: 100%;
					height: 300rpx;
				}
				.tit {
					padding: 20rpx;
					font-size: 32rpx;
				}
			}
		}
	}
}
</style>
